<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Novo Competencias_Docentes</title>
        <script type="text/javascript" src="../js/jquery.js" ></script>
        <script type="text/javascript" src="../js/jquery.validate.js"></script>
        <script type="text/javascript" src="../js/forms.js"></script>
        <script type="text/javascript" src="../js/jquery-ui-1.8.2.custom.min.js" ></script>
        <script type="text/javascript" src="../js/jquery.ui.datepicker-pt-BR.js" ></script>
        <link rel="stylesheet" href="../css/ui-lightness/jquery-ui-1.8.2.custom.css">
    <link rel="stylesheet" href="../css/forms.css"></head>
    <script>
        $(document).ready(function(){
            $("#form").validate({
                rules: {
                    id_competencia: {required: true,digits: true
                    }
                    ,matricula: {required: true}
                    ,prazo: {date: true
                    }
                    ,prioridade: {digits: true,required: true
                    }
                },
                submitHandler: function(form) {
                    salvar(form);
                }
            });

            $('#prazo').datepicker();
            $('#inicio').datepicker();
        });

        $(function() {
            var cache = {};
            $( "#competencia" ).autocomplete({
                minLength: 3,
                source: function(request, response) {
                    if ( request.term in cache ) {
                        response( cache[ request.term ] );
                        return;
                    }

                    $.ajax({
                        url: "../Competencias/fm_getCompetencias.jsp",
                        dataType: "json",
                        type: "POST",
                        data: request,
                        success: function( data ) {
                            cache[ request.term ] = data;
                            response( data );
                        }
                    });
                },
                select: function(event, ui) {
                    setCompetencia(ui.item ? (ui.item.id) : "");
                }
            });
        });
        function setCompetencia (txt){
            $("#id_competencia").val(txt);
        }
    </script>


    <body>

        <form name="form" id="form" method="post" action="insert.jsp" >
            <input type="hidden" name="matricula" value="${param.matricula}">
            <fieldset><legend>Dados</legend>
                <p><label class="lbInput">Competência<em>*</em></label>
                    <input type="text" value="" name="competencia" id="competencia" size="60">
                    <input type="hidden" value="" name="id_competencia" id="id_competencia">
                </p>
                <p><label class="lbInput">Início</label>
                    <input type="text" id="inicio" name="inicio" size="12" maxlength="12">
                </p>
                <p><label class="lbInput">Fim</label>
                    <input type="text" id="prazo" name="prazo" size="12" maxlength="12">
                </p>
                <p><label class="lbInput">Prioridade<em>*</em></label>
                    <input type="radio" name="prioridade" value="1" class="required"><label>Baixa</label>
                    <input type="radio" name="prioridade" value="2" maxlength="10" class="required" checked><label>Média</label>
                    <input type="radio" name="prioridade" value="3" maxlength="10" class="required"><label>Alta</label>
                </p>
                <p>
                    <input class="submit" type="submit" value="Salvar">
                    <input class="submit" type="button" value="Listar" onclick="listar('fm_lista_Competencias_Docentes.jsp')">
                </p>
                <div id="ajax_dados" style="display:block">
                </div>
                <div id="msg" style="display:none"></div>
            </fieldset>
        <input type="hidden" id="token" name="token" value="${sessionScope.token}" /> </form>
    </body>
</html>
